package com;

import com.go2.shipping.common.StringUtil;
import com.yuhang.demo.util.PostUtil;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.NameValuePair;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.util.*;

public class Test {
    public static final String PHONE_REG = "^(0|86|17951)?1[0-9]{10}$";

    public static void main(String[] args) throws IOException {

        File file = new File("D:/2.txt");
        BufferedReader br = new BufferedReader(new FileReader(file));
        String len = "";
        Long parent = 0L;
        Map<Long, String> map = new HashMap<>();
        while ((len = br.readLine()) != null) {
            if (len.startsWith("title")) {
                String[] xx = len.split(",");
                parent = Long.parseLong(xx[2].replaceAll("]","").split("=")[1]);
            }else{
               // System.out.println(parent + ":" + len);
                String v = map.get(parent);

                String[] strs = len.split("\t");
                String dict = len;
                if (strs.length == 2) {
                    dict = strs[1];
                }
                if (StringUtil.isNotEmpty(v)) {
                     v+=","+dict;
                }else{
                    v=dict;
                }
                map.put(parent,v);
            }

        }


        map.forEach((k,v)->{

            String values[]=v.split(",");
            for(int i=0;i<values.length;i++) {

                if(k.longValue()==1823){
                    continue;
                }
                System.out.println("INSERT INTO  `dict_area` (`id`, `code`, `name`, `parent`, `update_time`, `created_time`, `state`) VALUES (null, NULL, '" + values[i] + "', " + k + ", now(), now(), 'ENABLED');");
            }
            });

        System.out.println(map.keySet());
    }
}
